package com.example.Android_test.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import com.example.Android_test.R;
import com.example.Android_test.helpers.SettingsHelper;
import com.example.Android_test.util.LanguageUtils;

/**
 * Created with IntelliJ IDEA.
 * User: anpi0413
 * Date: 31.05.13
 * Time: 16:02
 * To change this template use File | Settings | File Templates.
 */
public class GlobalSettings extends Activity {
    private TextView gs_textView_homeLanguage;
    private TextView gs_textView_targetLanguage;
    private Button gs_button_changeHomeLanguage;
    private Button gs_button_changeTargetLanguage;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.other_global_settings);

        gs_textView_homeLanguage = (TextView) findViewById(R.id.gs_textViewHomeLanguage);
        gs_textView_homeLanguage.setText(SettingsHelper.INSTANCE.getCurrentLanguage().getDescription());
        gs_button_changeHomeLanguage = (Button) findViewById(R.id.gs_button_ChangeHomeLanguage);
        gs_button_changeHomeLanguage.setOnClickListener(new ButtonChangeHomeLanguageListener());

        gs_textView_targetLanguage = (TextView) findViewById(R.id.gs_textViewTargetLanguage);
        gs_button_changeTargetLanguage = (Button) findViewById(R.id.gs_button_ChangeTargetLanguage);
        gs_button_changeTargetLanguage.setOnClickListener(new ButtonChangeTargetLanguageListener());

       /* gs_log = (TextView) findViewById(R.id.gs_textViewLog);

        String log = "";
        log += "ETR " + SettingsHelper.INSTANCE.getStringPreference(SettingsHelper.KEY_TRAINING_TIME_SPENT_ETR);
        log += "GD " + SettingsHelper.INSTANCE.getStringPreference(SettingsHelper.KEY_TRAINING_TIME_SPENT_GD);
        log += "PUWIC " + SettingsHelper.INSTANCE.getStringPreference(SettingsHelper.KEY_TRAINING_TIME_SPENT_PUWIC);
        log += "SPRINT " + SettingsHelper.INSTANCE.getStringPreference(SettingsHelper.KEY_TRAINING_TIME_SPENT_SPRINT);
        log += "TW " + SettingsHelper.INSTANCE.getStringPreference(SettingsHelper.KEY_TRAINING_TIME_SPENT_TW);
        gs_log.setText(log);*/
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        if(resultCode == RESULT_OK){
            setResult(RESULT_OK, null);
            finish();
        }
    }

    private void calculateStat() {

    }

    private class ButtonChangeHomeLanguageListener implements View.OnClickListener {
        @Override
        public void onClick(View v) {
            /*Intent intent = new Intent(Main.getAppContext(), SelectLanguage.class);
            startActivity(intent);*/

            Intent intent = new Intent(GlobalSettings.this, SelectLanguage.class);
            startActivityForResult(intent, 1);
        }
    }

    private class ButtonChangeTargetLanguageListener implements View.OnClickListener {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(Main.getAppContext(), SelectLanguage.class);
            startActivity(intent);
        }
    }
}